package com.hko.qrip.dao.impl;

import java.sql.SQLException;
import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hko.qrip.dao.FtpLogDao;
import com.ibatis.sqlmap.client.SqlMapClient;

@Component("ftpLogDao")
public class FtpLogDaoImpl implements FtpLogDao {
	@Autowired
	private SqlMapClient sqlMapClient;

	@Override
	public int insertFtpLog(String logMsg) {
		try {
			return sqlMapClient.update("insertFtpLog", logMsg);
		} catch (SQLException e) {

			return 0;
		}

	}

	@Override
	public int insertTableLog(String filename, int rowChanged, int rowInFile, String description) {
		if (rowInFile == 0) {
			return 0;
		}
		try {
			HashMap<String, String> map = new HashMap<String, String>();
			map.put("filename", filename);
			map.put("rowChanged", String.valueOf(rowChanged));
			map.put("rowInFile", String.valueOf(rowInFile));
			map.put("description", description);
			return sqlMapClient.update("insertTableLog", map);
		} catch (SQLException e) {

			return 0;
		}

	}
}
